import request from '@/utils/request'

// 查询已发货仅退款列表
export function listYfhjtk(query) {
  return request({
    url: '/aft/yfhjtk/list',
    method: 'get',
    params: query
  })
}

// 查询已发货仅退款详细
export function getYfhjtk(id) {
  return request({
    url: '/aft/yfhjtk/' + id,
    method: 'get'
  })
}

// 新增已发货仅退款
export function addYfhjtk(data) {
  return request({
    url: '/aft/yfhjtk',
    method: 'post',
    data: data
  })
}

// 修改已发货仅退款
export function updateYfhjtk(data) {
  return request({
    url: '/aft/yfhjtk',
    method: 'put',
    data: data
  })
}

// 删除已发货仅退款
export function delYfhjtk(id) {
  return request({
    url: '/aft/yfhjtk/' + id,
    method: 'delete'
  })
}

export function checkTime(time){
  console.log("-------------------time>>>>>>>>",time)
  //
  if(time.indexOf("时") !== -1 && time.indexOf("分") !== -1 &&time.indexOf("秒") !== -1){
    let matches = time.match(/(\d+)时(\d+)分(\d+)秒/);

    var hour = parseInt(matches[1]);
    var min = parseInt(matches[2]);
    var sec = parseInt(matches[3]);
    // console.log("hour+'时'+min+'分'+sec+'秒'>>>>>>>>",(hour+'时'+min+'分'+sec+'秒'))
    var s = Number(hour * 3600) + Number(min * 60) + Number(sec)
    //毫秒
    var millis = s * 1000
    const longTimes = Math.max(0, millis - 1)
    // console.log("longTimes>>>>>>>>",longTimes)
    const hours = Math.floor(longTimes / 3600000);
    // console.log("hours>>>>>>>>",hours)
    const minutes = Math.floor((longTimes % 3600000) / 60000);
    // console.log("minutes>>>>>>>>",minutes)
    const seconds = Math.floor((longTimes % 60000) / 1000);
    // console.log("seconds>>>>>>>>",seconds)

    // console.log("hours+'时'+minutes+'分'+seconds+'秒'>>>>>>>>",(hours+'时'+minutes+'分'+seconds+'秒'))

    return hours+'时'+minutes+'分'+seconds+'秒';
  }else{
    return time;
  }

}
